package com.example.everying.service.system.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.everying.mapper.system.ScheduleJobMapper;
import com.example.everying.model.job.ScheduleJob;
import com.example.everying.service.system.ScheduleJobService;
import com.example.everying.utils.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @program: everything
 * @description:
 * @author: zw
 * @create: 2025-07-09 11:38
 **/
@Service
public class ScheduledJobServiceImpl extends ServiceImpl<ScheduleJobMapper, ScheduleJob> implements ScheduleJobService {
    @Override
    public IPage<ScheduleJob> slectPage(Page<ScheduleJob> pageParam, ScheduleJob query) {
        QueryWrapper<ScheduleJob> queryWrapper = new QueryWrapper<>();
        if (query != null){
            queryWrapper.orderByDesc("create_time");
            queryWrapper.eq("is_delete",0);
            if (!StringUtils.isEmpty(query.getJobId())) {
                queryWrapper.eq("job_id", query.getJobId());
            }
            if (!StringUtils.isEmpty(query.getJobName())) {
                queryWrapper.like("job_name", query.getJobName());
            }
        }
        Page<ScheduleJob> pageModel = baseMapper.selectPage(pageParam, queryWrapper);
        return pageModel;
    }
}
